/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ComponenteEntidad;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Marilyn
 */
@Entity
@Table(name = "persona")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
    @NamedQuery(name = "Persona.findByIdPersona", query = "SELECT p FROM Persona p WHERE p.idPersona = :idPersona"),
    @NamedQuery(name = "Persona.findByPerDNI", query = "SELECT p FROM Persona p WHERE p.perDNI = :perDNI"),
    @NamedQuery(name = "Persona.findByPerNombres", query = "SELECT p FROM Persona p WHERE p.perNombres = :perNombres"),
    @NamedQuery(name = "Persona.findByPerApellidos", query = "SELECT p FROM Persona p WHERE p.perApellidos = :perApellidos"),
    @NamedQuery(name = "Persona.findByPerDireccion", query = "SELECT p FROM Persona p WHERE p.perDireccion = :perDireccion"),
    @NamedQuery(name = "Persona.findByPerSexo", query = "SELECT p FROM Persona p WHERE p.perSexo = :perSexo"),
    @NamedQuery(name = "Persona.findByPerTelf", query = "SELECT p FROM Persona p WHERE p.perTelf = :perTelf"),
    @NamedQuery(name = "Persona.findByPerCel", query = "SELECT p FROM Persona p WHERE p.perCel = :perCel"),
    @NamedQuery(name = "Persona.findByPerTipo", query = "SELECT p FROM Persona p WHERE p.perTipo = :perTipo"),
    @NamedQuery(name = "Persona.findByPerFechaCreacion", query = "SELECT p FROM Persona p WHERE p.perFechaCreacion = :perFechaCreacion"),
    @NamedQuery(name = "Persona.findByPerFechaNac", query = "SELECT p FROM Persona p WHERE p.perFechaNac = :perFechaNac")})
public class Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idPersona")
    private Integer idPersona;
    @Size(max = 10)
    @Column(name = "per_DNI")
    private String perDNI;
    @Size(max = 60)
    @Column(name = "per_Nombres")
    private String perNombres;
    @Size(max = 60)
    @Column(name = "per_Apellidos")
    private String perApellidos;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "per_Direccion")
    private String perDireccion;
    @Column(name = "per_Sexo")
    private Character perSexo;
    @Size(max = 100)
    @Column(name = "per_Telf")
    private String perTelf;
    @Size(max = 100)
    @Column(name = "per_Cel")
    private String perCel;
    @Column(name = "per_Tipo")
    private Integer perTipo;
    @Column(name = "per_FechaCreacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date perFechaCreacion;
    @Column(name = "per_FechaNac")
    @Temporal(TemporalType.DATE)
    private Date perFechaNac;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.LAZY)
    private Empleado empleado;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.LAZY)
    private Cliente cliente;

    public Persona() {
    }

    public Persona(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public Persona(Integer idPersona, String perDireccion) {
        this.idPersona = idPersona;
        this.perDireccion = perDireccion;
    }

    public Integer getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public String getPerDNI() {
        return perDNI;
    }

    public void setPerDNI(String perDNI) {
        this.perDNI = perDNI;
    }

    public String getPerNombres() {
        return perNombres;
    }

    public void setPerNombres(String perNombres) {
        this.perNombres = perNombres;
    }

    public String getPerApellidos() {
        return perApellidos;
    }

    public void setPerApellidos(String perApellidos) {
        this.perApellidos = perApellidos;
    }

    public String getPerDireccion() {
        return perDireccion;
    }

    public void setPerDireccion(String perDireccion) {
        this.perDireccion = perDireccion;
    }

    public Character getPerSexo() {
        return perSexo;
    }

    public void setPerSexo(Character perSexo) {
        this.perSexo = perSexo;
    }

    public String getPerTelf() {
        return perTelf;
    }

    public void setPerTelf(String perTelf) {
        this.perTelf = perTelf;
    }

    public String getPerCel() {
        return perCel;
    }

    public void setPerCel(String perCel) {
        this.perCel = perCel;
    }

    public Integer getPerTipo() {
        return perTipo;
    }

    public void setPerTipo(Integer perTipo) {
        this.perTipo = perTipo;
    }

    public Date getPerFechaCreacion() {
        return perFechaCreacion;
    }

    public void setPerFechaCreacion(Date perFechaCreacion) {
        this.perFechaCreacion = perFechaCreacion;
    }

    public Date getPerFechaNac() {
        return perFechaNac;
    }

    public void setPerFechaNac(Date perFechaNac) {
        this.perFechaNac = perFechaNac;
    }

    public Empleado getEmpleado() {
        return empleado;
    }

    public void setEmpleado(Empleado empleado) {
        this.empleado = empleado;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersona != null ? idPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.idPersona == null && other.idPersona != null) || (this.idPersona != null && !this.idPersona.equals(other.idPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ComponenteEntidad.Persona[ idPersona=" + idPersona + " ]";
    }
    
}
